<!DOCTYPE html>
<html>
<head>
<title>Same origin test</title>
</head>
<body>
<iframe id="sub1" src="http://127.0.0.1:8000/security/resources/empty.html">
</iframe>
<script>
// This file should be loaded as an iframe hosted on 127.0.0.1:8000.

// This test creates a subframe, then detaches it and clones it. All of
// the agent IDs should be the same.

function run(evt) {
  let sub1 = document.getElementById('sub1');
  let sub1_window = sub1.contentWindow;
  sub1.remove();

  let message = [
    'same-origin detach test',
    internals.getAgentId(window),
    internals.getAgentId(sub1_window)
  ];

  window.parent.postMessage(message, '*');
}

window.addEventListener('load', run, {'once': true});
</script>
</body>
</html>
